find_package(PkgConfig)
pkg_check_modules(PC_CAIROMM  cairomm-1.16)

find_path(CAIROMM_INCLUDE_DIRS
    NAMES cairommconfig.h
    HINTS ${PC_CAIROMM_INCLUDEDIR}
    ${PC_CAIROMM_INCLUDE_DIRS}
)

find_library(CAIROMM_LIBRARIES
    NAMES cairomm-1.16
    HINTS ${PC_CAIROMM_LIBDIR}
    ${PC_CAIROMM_LIBRARY_DIRS}
)
#message(FATAL_ERROR "PC_CAIROMM_INCLUDEDIR=${PC_CAIROMM_INCLUDEDIR} PC_CAIROMM_LIBDIR=${PC_CAIROMM_LIBDIR} CAIROMM_LIBRARIES=${CAIROMM_LIBRARIES}")
if(CAIROMM_INCLUDE_DIRS AND CAIROMM_LIBRARIES)
    set(CAIROMM_FOUND TRUE)
    set(CAIROMM_LIBRARY ${CAIROMM_LIBRARIES})
    set(CAIROMM_INCLUDE_DIR ${CAIROMM_INCLUDE_DIRS})
    set(CAIROMM_VERSION ${PC_CAIROMM_VERSION})

    if(NOT TARGET CairoMM::CairoMM)
     add_library(CairoMM::CairoMM UNKNOWN IMPORTED)
     if(CAIROMM_INCLUDE_DIRS)
       set_target_properties(CairoMM::CairoMM PROPERTIES
         INTERFACE_INCLUDE_DIRECTORIES "${CAIROMM_INCLUDE_DIRS}")
     endif()
     if(EXISTS "${CAIROMM_LIBRARY}")
       set_target_properties(CairoMM::CairoMM PROPERTIES
         IMPORTED_LINK_INTERFACE_LANGUAGES "C"
         IMPORTED_LOCATION "${CAIROMM_LIBRARY}")
     endif()
     if(EXISTS "${CAIROMM_LIBRARY_RELEASE}")
         set_property(TARGET CairoMM::CairoMM APPEND PROPERTY
            IMPORTED_CONFIGURATIONS RELEASE)
         set_target_properties(CairoMM::CairoMM PROPERTIES
            IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
            IMPORTED_LOCATION_RELEASE "${CAIROMM_LIBRARY_RELEASE}")
     endif()
     if(EXISTS "${CAIROMM_LIBRARY_DEBUG}")
         set_property(TARGET CairoMM::CairoMM APPEND PROPERTY
            IMPORTED_CONFIGURATIONS DEBUG)
         set_target_properties(CairoMM::CairoMM PROPERTIES
            IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
            IMPORTED_LOCATION_DEBUG "${CAIROMM_LIBRARY_DEBUG}")
     endif()
   endif()
endif()

#message("CAIROMM_LIBRARIES=${CAIROMM_LIBRARIES} CAIROMM_FOUND=${CAIROMM_FOUND}")
include(FindPackageHandleStandardArgs)
#FIND_PACKAGE_HANDLE_STANDARD_ARGS(CAIROMM REQUIRED_VARS CAIROMM_INCLUDE_DIRS CAIROMM_LIBRARIES 
#	FOUND_VAR CAIROMM_FOUND VERSION_VAR CAIROMM_VERSION)

mark_as_advanced(CAIROMM_LIBRARIES CAIROMM_LIBRARY CAIROMM_INCLUDE_DIRS CAIROMM_INCLUDE_DIR CAIROMM_FOUND)

